package com.diandian.backend.kuaishou.life.exchange.controller;

import com.diandian.backend.kuaishou.life.exchange.service.BusinessTokenGetService;
import com.diandian.base.boot.starter.response.BaseResult;
import com.diandian.kuaishou.life.boot.starter.param.DecryptBatchParam;
import com.diandian.kuaishou.life.boot.starter.service.KuaiShouDecryptBasicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/decrypt")
public class DecryptController {

    @Autowired
    private KuaiShouDecryptBasicService decryptBasicService;

    @Autowired
    private BusinessTokenGetService businessTokenGetService;

    /**
     * 批量解密密文信息
     */
    @PostMapping( "/batch")
    public BaseResult batchDecrypt(@RequestHeader(name = "appKey") String appKey,
                                   @RequestHeader(name = "appSecret") String appSecret,
                                   @RequestHeader(value = "merchantId") String merchantId,
                                   @RequestBody DecryptBatchParam param) {
        String accessToken = businessTokenGetService.getToken(appKey, appSecret, merchantId);
        return new BaseResult(0, "success", decryptBasicService.batchDecrypt(accessToken, param));
    }

}
